package org.apache.lucene.demo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class TestMain {

    // 中国
    private static String CHARSET = "UTF-8";

    public static void test(String[] args) throws IOException {

        InputStreamReader read = new InputStreamReader(System.in, CHARSET);
        BufferedReader in = new BufferedReader(read);
        //        BufferedReader in = new BufferedReader(new InputStreamReader(System.in, CHARSET));
        while (true) {
            System.out.println("please write : ");
            byte[] bytes = in.readLine().getBytes(CHARSET);
            String line = new String(bytes);
            System.out.println(line);
            if (line.equalsIgnoreCase("q")) {
                break;
            }
        }
    }

    public static void main(String[] args) {
        //数组缓冲
        byte[] b = new byte[1024];
        //有效数据个数
        int n = 0;
        try {
            while (true) {
                //提示信息
                System.out.println("请输入：");
                //读取数据
                n = System.in.read(b);
                //转换为字符串
                String s = new String(b, 0, n - 2);
                //判断是否是quit
                if (s.equalsIgnoreCase("q")) {
                    break; //结束循环
                }
                //回显内容
                System.out.println("输入内容为：" + s);
            }
        } catch (Exception e) {
        }
    }

}
